#include "ps_es_adaptation.h"


/*
* Function:     	ps_es_adaptation_process
* Input:         	src_buffer  src_len
* Output:        	int
* Return:         	-1 --->error(input)
*                    0  --->H264
*                    1  --->PS
*/
int ps_es_adaptation_process(char *src_buffer,int src_len)
{
    if(src_buffer == NULL)
        return -1;
    if(src_len < 10)
        return -1;
        
    int cur_buf_Addr = 0;

    while (cur_buf_Addr < src_len - 5)
    {

        if ( (src_buffer[cur_buf_Addr+0] & 0xff) == 0x00 &&
             (src_buffer[cur_buf_Addr+1] & 0xff) == 0x00 &&
             (src_buffer[cur_buf_Addr+2] & 0xff) == 0x01) 
        {
            if( ((src_buffer[cur_buf_Addr+3] & 0xff) == 0xBA) ||
                ((src_buffer[cur_buf_Addr+3] & 0xff) == 0xBB) ||
                ((src_buffer[cur_buf_Addr+3] & 0xff) == 0xBC) ||
                ((src_buffer[cur_buf_Addr+3] & 0xff) == 0xE0) ||
                ((src_buffer[cur_buf_Addr+3] & 0xff) == 0xC0)  )
            {
                //printf("find ES header\n");
                return 1;
            }
            else
            {
                cur_buf_Addr++;
                continue;
            }
        }
        else
        {
            cur_buf_Addr++;
        }
    }
    return 0;
}
